<template>
  <bjSelect
    v-bind="$attrs"
    v-on="$listeners"
    :placeholder="placeholder"
    :replaceFields="replaceFields"
    :dataResource="list"
    :loading="loading"
    :value.sync="value"
    :disabled="disabled"
  ></bjSelect>
</template>

<script>
/**  查询标段  **/
import bjSelect from "@/components/bj-select";
import { getLoginData } from "@/tools";
import { getBlockList } from "@/api/wisdom-beam/cement_common";
export default {
  name: "SelectBlock",
  model: {
    prop: "value",
    event: "change",
  },
  props: {
    placeholder: {
      type: String,
      default: "请选择标段",
    },
    value: {
      type: [Object, Array],
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    manual: {
      type: Boolean,
      default: true,
    },
  },
  components: {
    bjSelect,
  },

  data() {
    return {
      loading: true,
      replaceFields: { key: "orgCode", label: "orgName" },
      list: [],
    };
  },
  mounted() {
    this.render();
  },
  methods: {
    render() {
      this.getListData();
    },
    //查询标段信息
    getListData() {
      let { userId, tenantCode } = getLoginData();
      this.loading = true;
      getBlockList({ tenantCode, userId })
        .then((res) => {
          let { data } = res;
          this.list = data.result || [];
          this.loading = false;
          this.emitResponse(res);
        })
        .catch((_) => {
          this.loading = false;
          this.list = [];
          this.emitResponse(null);
        });
    },

    emitResponse(data = null) {
      this.$nextTick((_) => {
        this.$emit("response", data);
      });
    },
  },
};
</script>

<style></style>
